﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MVCPets.Helpers
{
  public static class ConversionHelpers
  {
    public static T ConvertItem<T>(object value, T defaultValue)
    {
      if (value == null) { return defaultValue; }

      try
      {
        return (T)Convert.ChangeType(value, typeof(T));
      }
      catch (Exception)
      {
        return defaultValue;
      }
    }
  }
}
